<?php

namespace App\Providers;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\DB;
class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $config=$this->getConfig();
        $link=$this->getLink();
        View::share('config', $config);
        View::share('link', $link);
    }
    // 获取网站配置
    private function getConfig(){
        $config=DB::table('config')->get();
        $arr=[];
        foreach($config as $item){
            $arr[$item->name]=json_decode($item->config);
        }
        return $arr;
    }
    // 获取友情链接
    private function getLink(){
        $link=DB::table('friends')->get();
        return $link;
    }
}
